class Address {

    static belongsTo = [Company]

    String line1
    String line2
    String suite
    String city
    State state
    String country = "USA"
    String postalCode

    static constraints = {
        line1(nullable:false, blank:false)
        line2(nullable:true, blank:false)
        suite(nullable:true, blank:false)
        city(nullable:false, blank:false)
        state(nullable:false, blank:false)
        country(nullable:false, blank:false)
        postalCode(postalCode:true, blank:false)
    }

    String toString() {
        def str = line1
        if (line2) {
            str += "\n${line2}"
        }
        if (suite) {
            str += "\n${suite}"
        }
        str += "\n${city}"
        str += "\n${state}"
        str += "\n${postalCode}"
    }

    String singleLineString() {
        return line1 + ", " + city + ", " + state + " " + postalCode
    }
}
